﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace skvote
{
    public partial class admin_system : System.Web.UI.Page
    {
        private config cfg = new config();
        private OleDbConnection connection = new conn().CreateConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            function.check();            
        }
        public string WebName()
        {
            return cfg.getWebName();
        }
        public string WebUrl()
        {
            return cfg.getWebUrl();
        }
        public string SystemUrl()
        {
            return cfg.getSystemUrl();
        }
        public string RestrictIP(string bRestrict)
        {
            if (cfg.getRestrictIP().ToString().Trim().ToLower() == bRestrict.Trim().ToLower())
            {
                return "selected";
            }
            else
            {
                return ""; 
            }
            
        }
        public string RefuseTime(string time)
        {
            if (cfg.getRefuseTime().ToString() == time)
            {
                return "selected";
            }
            else
            {
                return "";
            }
        }
        public string AllowView(string allow)
        {
            if (cfg.getAllowView().ToString().ToLower() == allow.Trim().ToLower())
            {
                return "selected";
            }
            else
            {
                return "";
            }
        }
        public string UserInfo(string userInfo)
        {
            if (cfg.getUserInfo().ToString().ToLower().Trim() == userInfo.Trim().ToLower())
            {
                return "selected";
            }
            else
            {
                return "";
            }
        }

        protected void btn_Click(object sender, EventArgs e)
        {
            try
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                string sql = "UPDATE XH_Config SET [webname]=\"" + Request["WebName"] + "\",[weburl]=\"" + Request["WebUrl"] + "\",[systemurl]=\"" + Request["SystemUrl"] + "\",[restrictIP]=" + Request["restrictIP"] + ",[allowview]=" + Request["AllowView"] + ",[refuseTime]=" + Request["refuseTime"] + ",[getuserinfo]=" + Request["getuserinfo"];
                OleDbCommand OleCmd = new OleDbCommand(sql, connection);
                OleCmd.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
            }
            function.successMsg("修改配置信息成功");
        }
    }
}
